package com.yhy.wxzn.wcs.utils;

import com.yhy.wxzn.wcs.device.rgv.bean.FourWayRgv;
import com.yhy.wxzn.wcs.device.rgv.bean.Node;
import com.yhy.wxzn.wcs.device.rgv.enums.PriorityCodes;
import com.yhy.wxzn.wcs.device.rgv.enums.RgvProgress;
import com.yhy.wxzn.wcs.entity.WcsTask;
import com.yhy.wxzn.wcs.enums.PlcTaskProgress;
import com.yhy.wxzn.wcs.enums.RgvTaskAssignStatus;
import com.yhy.wxzn.wcs.enums.TaskStatus;
import com.yhy.wxzn.wcs.enums.TaskType;

import java.util.Date;

public class TaskUtils {

    public static WcsTask generateRgvTask(TaskType taskType, Node start,Node end,int priorityCode){
        WcsTask task = new WcsTask();
        task.setAssignStatus(RgvTaskAssignStatus.UNASSIGNED);
        task.setTaskType(taskType);
        task.setStart(start == null ? null : start.toString());
        task.setEnd(end.toString());
        task.setPlcProgress(PlcTaskProgress.ALL_DEVICE_COMPLETE.getTaskProgress());
        task.setTaskStatus(TaskStatus.NEW);
        task.setRgvProgress(RgvProgress.NOT_ASSIGNED_TO_RGV);
        task.setPriorityCode(priorityCode);
        task.setCreateTime(new Date());
        return task;
    }

    public static WcsTask generateRgvTask(TaskType taskType, Node start, Node end, int priorityCode, FourWayRgv rgv){
        WcsTask task = new WcsTask();
        task.setAssignStatus(RgvTaskAssignStatus.ASSIGNED);
        task.setProcessRgvDeviceCode(rgv.getDeviceInfo().getId());
        task.setTaskType(taskType);
        task.setStart(start == null ? null : start.toString());
        task.setEnd(end.toString());
        task.setPlcProgress(PlcTaskProgress.ALL_DEVICE_COMPLETE.getTaskProgress());
        task.setTaskStatus(TaskStatus.NEW);
        task.setRgvProgress(RgvProgress.ASSIGNED_TO_RGV);
        task.setPriorityCode(priorityCode);
        task.setCreateTime(new Date());
        return task;
    }
}
